package com.atguigu.flink.chapter01_moni;

import lombok.SneakyThrows;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

/**
 * Created by Smexy on 2022/10/21
 *
 *  一个Task，负责执行算子的核心功能（自己定义，Flink已经实现(KeyBy)）
 */
public class MyTask implements Runnable
{
    private MyFlatMapFunction myFlatMapFunction1;

    //private SumFunction
   // private MyFlatMapFunction myFlatMapFunction2;

    public String receiveShangYouData(){
        return "";
    }

    @SneakyThrows
    @Override
    public void run() {
        //通过网络接收上游的数据
        String data = receiveShangYouData();

        //执行算子的核心功能
        myFlatMapFunction1.flatMap(data, new Collector<Tuple2<String, Integer>>()
        {
            @Override
            public void collect(Tuple2<String, Integer> record) {

                //把处理的结果发送到下游
            }

            @Override
            public void close() {

            }
        });

        //sum

       /* myFlatMapFunction2.flatMap(data, new Collector<Tuple2<String, Integer>>()
        {
            @Override
            public void collect(Tuple2<String, Integer> record) {

                //把处理的结果发送到下游
            }

            @Override
            public void close() {

            }
        });*/



    }
}
